package com.iot.server.common.core;

import com.iot.core.domain.BaseDO;
import com.iot.core.domain.PageDO;

import java.util.List;
import java.util.Map;

public interface BaseMapper<T> {

    String SQL_INSERT = "insert";
    String SQL_INSERT_SELECTIVE = "insertSelective";
    String SQL_BATCH_INSERT = "batchInsert";

    String SQL_DELETE_BY_ID = "deleteByPrimaryKey";
    String SQL_DELETE_BY_ENTITY = "deleteByEntity";
    String SQL_BATCH_DELETE_BY_IDS = "batchDeleteByPrimaryKey";
    String SQL_BATCH_DELETE_BY_MAP = "batchDeleteByMap";

    String SQL_SELECT_BY_ID = "selectByPrimaryKey";
    String SQL_SELECT_BY_MAP = "selectByMap";
    String SQL_SELECT_BY_ENTITY = "selectByEntity";

    String SQL_UPDATE_SELECTIVE = "updateByPrimaryKeySelective";
    String SQL_UPDATE = "updateByPrimaryKey";

    String SQL_LIST_BY_PAGE = "listByPage";

    String SQL_LIST_BY_MAP = "listByMap";
    String SQL_LIST_BY_ENTITY = "listByEntity";

    int insert(T record);

    int insertSelective(T record);

    int batchInsert(List<T> list);

    int batchInsert(List<T> list, int size);

    int insertByParams(String sqlId, Object parameter);

    int deleteByPrimaryKey(String id);

    int deleteByEntity(T record);

    int deleteByParams(String sqlId, Object parameter);

    int batchDeleteByPrimaryKey(List<String> ids);

    int batchDeleteByMap(Map<String, Object> params);

    T selectByPrimaryKey(String id);

    T selectByMap(Map<String, Object> paramMap);

    T selectByParams(String sqlId, Map<String, Object> paramMap);

    T selectByEntity(T entity);

    T selectByEntity(String sqlId, T entity);

    int updateByPrimaryKeySelective(T record);

    int updateByPrimaryKey(T record);

    int updateBatch(List<T> list);

    int updateByParams(String sqlId, Object parameter);

    int getCountByEntity(String sqlId, T entity);

    Object getlistResultByEntity(String sqlId, T entity);

    Object selectByMap(String sqlId, Map<String, Object> paramMap);
    int getCountByParams(String sqlId, Map<String, Object> paramMap);

    /**
     * 分页查询
     */
    PageDO<T> listByPage(T entity);

    PageDO<T> listByPage(T entity, String sqlId);

    /**
     * 自定义分页对象的分页查询
     * @param entity 查询条件对象
     * @param clazz 分页对象
     * @param sqlId
     * @param <E>
     * @return
     */
    <E extends BaseDO> PageDO<E> listByPage(T entity, Class<E> clazz, String sqlId);

    /**
     * 自定义分页对象及传入参数的分页查询
     * @param entity
     * @param clazz
     * @param sqlId
     * @param <E>
     * @return
     */
    <E extends BaseDO> PageDO<E> listOtherPage(E entity, Class<E> clazz, String sqlId);

    List<T> listByMap(Map<String, Object> paramMap);

    List<T> listByMap(Map<String, Object> paramMap, String sqlId);

    List<T> listByEntity(T entity);

    List<T> listByEntity(T entity, String sqlId);

    List<T> selectListPageByEntity(String sqlId, T entity);
}
